import doT from '../../../../vendor/template/doT.js';
import { requestFilePath } from "../../../common/api/file-request.js";
import watermark from '../../../common/watermark.js';
import entryRegistrationApi from '../../../common/api/breed/addentryrgst.api.js'

(function (window, document, $) {
    let _speLevelList, listindex = "";
    // 获取参数
    const _json = Utils.ParsingUrl(window.location);
    const lksalesmainTemplate = doT.template($('#looksalesplanmain-template').text());
    $(function () {
        $('body').attr('data-weui-theme', 'light'); //强制光明模式
        _watermarkBgImg();
        _initCommand()
    });

    //返回列表
    $(document).on('click', '#returnlist', function () {
        location.href = `./entryrgstlist.html?v=${Utils.GetTime()}`;
    });

    //命令初始化
    const _initCommand = async () => {
        let ids = getUrlKey("id")
        entryRegistrationApi.queryEntryRegistration(ids).then(async res => {
            console.log(res)
            $('#looksalesMain').empty().append(lksalesmainTemplate(res));
        });
    }

    /** 获取地址栏的 参数  传入 字段返回值 */
    const getUrlKey = (name) => {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]); return null;
    }

    // 添加水印信息
    const _watermarkBgImg = () => {
        let _userInfo = JSON.parse(Utils.GetSessionStorage("SNAccountEply")) || {};
        watermark.set(_userInfo.name + _userInfo.numCode);// 水印
    }

})(window, document, jQuery)